package com.yugao.fintech.framework.desensitization.fieldsensitive;

import com.yugao.fintech.framework.desensitization.annotations.FieldSensitive;
import com.yugao.fintech.framework.desensitization.fieldsensitive.enums.StrategyType;
import com.yugao.fintech.framework.desensitization.fieldsensitive.inter.IFieldSensitiveAnnotationGetter;
import com.yugao.fintech.framework.desensitization.fieldsensitive.model.FieldSensitiveAnnotationData;
import org.springframework.stereotype.Component;


@Component
public class DefaultFieldSensitiveAnnotationGetter implements IFieldSensitiveAnnotationGetter<FieldSensitive> {
    @Override
    public FieldSensitiveAnnotationData getData(FieldSensitive anno) {
        StrategyType strategy = anno.strategy();
        StrategyType value = anno.value();
        if (value != StrategyType.DEFAULT) {
            strategy = value;
        }
        return FieldSensitiveAnnotationData.builder().dataProcessor(strategy.getDataProcessor()).build();
    }
}
